/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * com_distri_clasif_viajes.java
 *
 * Created on 7/06/2011, 05:30:48 PM
 */

package sie_invdis;



import java.awt.print.PrinterException;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
import java.text.*;
import java.text.ParseException;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Michelle
 */
public class com_distri_clasif_viajes extends javax.swing.JFrame {

      private javax.swing.table.DefaultTableModel jtable_modelo;

      private int buscamp=1,opbuscamp=1,control_enter=0;

      DefaultTableCellRenderer alinearCentro, alinearderecha, alinearIzquierda;
      private bd_conexion x = new bd_conexion() ;
       //se creaa la variable resultset
      private ResultSet rs = null;

    private SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
    private SimpleDateFormat formateadoresta = new SimpleDateFormat("yyyy-MM-dd");
    /** Creates new form com_distri_clasif_viajes */
    public com_distri_clasif_viajes() {
        this.iniciar_modelo_de_tabla();
        initComponents();
        this.cargar_datos(3, 0, "");

         jtb_catalogo_articulos.getColumnModel().getColumn(0).setPreferredWidth(120);//Codigo
        jtb_catalogo_articulos.getColumnModel().getColumn(1).setPreferredWidth(60);//Descripcion
        jtb_catalogo_articulos.getColumnModel().getColumn(2).setPreferredWidth(60);//control almacen
        jtb_catalogo_articulos.getColumnModel().getColumn(3).setPreferredWidth(60);//Item
       jtb_catalogo_articulos.getColumnModel().getColumn(4).setPreferredWidth(45);//unidad E.
        jtb_catalogo_articulos.getColumnModel().getColumn(5).setPreferredWidth(45);//factor
        jtb_catalogo_articulos.getColumnModel().getColumn(6).setPreferredWidth(45);//Unidad Salida
        jtb_catalogo_articulos.getColumnModel().getColumn(7).setPreferredWidth(45);//Pz entrada


    }


public void centrar_datos()
    {
        alinearderecha = new DefaultTableCellRenderer();
        alinearderecha.setHorizontalAlignment(SwingConstants.RIGHT);

        jtb_catalogo_articulos.getColumnModel().getColumn(5).setCellRenderer(alinearderecha);
        jtb_catalogo_articulos.getColumnModel().getColumn(6).setCellRenderer(alinearderecha);
          jtb_catalogo_articulos.getColumnModel().getColumn(7).setCellRenderer(alinearderecha);
        jtb_catalogo_articulos.getColumnModel().getColumn(8).setCellRenderer(alinearderecha);

    }

   private void iniciar_modelo_de_tabla()
    {
        jtable_modelo=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo.addColumn("<html><b>Viaje</b></html>");
        jtable_modelo.addColumn("<html><b>F. Iinicio</b></html>");
        jtable_modelo.addColumn("<html><b>F. Fin</b></html>");
        jtable_modelo.addColumn("<html><b>Observacion</b></html>");
        jtable_modelo.addColumn("<html><b>Pedimento</b></html>");
        jtable_modelo.addColumn("<html><b>Piezas</b></html>");
        jtable_modelo.addColumn("<html><b>Importe Costo</b></html>");
        jtable_modelo.addColumn("<html><b>Imp. Costo Dist.</b></html>");
        jtable_modelo.addColumn("<html><b>Imp. Precio Publico</b></html>");

    }

private void cargar_datos(int opcion, int opbuscamp,String busqueda)
    {
      //se crea intancia de la clase conexion
      DecimalFormat miformat = new DecimalFormat("###,###,###,###");
      float tpz=0,tc=0,tcd=0,tpv=0;
      Object[] fnewRow = new Object[15];
      String fechallegatienda="",fechaentrega="";
      while(jtable_modelo.getRowCount()>0)jtable_modelo.removeRow(0);
       //rs = x.damecat_art(0,0,"");
       String texto="select * from x1distribucion_terminados_viajes("+opcion+","+opbuscamp+",'"+busqueda+"') as (id integer,descripclasif character varying(30),fechai date,fechafin date,observacion character varying(255),pedimento character varying(80),totalpieza numeric,totentrada numeric,totalcossal numeric,totalprepub numeric)";
       try
         {
           rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
            while (rs.next())
                {
                    fechallegatienda="";
                    fechaentrega="";
                    fnewRow[0]=rs.getString ("id")+":"+rs.getString ("descripclasif");
                    if(rs.getString("fechai") != null)
                        {
                           fechallegatienda="<html>"+this.fechaeuropea(rs.getString("fechai"))+":"+DiaSemana(rs.getString ("fechai"))+"</html>";
                        }
                    fnewRow[1]=fechallegatienda;
                    if(rs.getString("fechafin") != null )
                        {
                            fechaentrega="<html>"+this.fechaeuropea(rs.getString ("fechafin"))+":"+this.DiaSemana(rs.getString("fechafin"))+"</html>";
                        }
                    fnewRow[2]=fechaentrega;
                    fnewRow[3]=rs.getString("observacion");
                    fnewRow[4]=rs.getString("pedimento");
                    fnewRow[5]=miformat.format(rs.getFloat("totalpieza"));
                    fnewRow[6]=miformat.format(rs.getFloat("totentrada"));
                    fnewRow[7]=miformat.format(rs.getFloat("totalcossal"));
                    fnewRow[8]=miformat.format(rs.getFloat("totalprepub"));

                    jtable_modelo.addRow(fnewRow);
                    tpz+=rs.getFloat("totalpieza");
                            tc+=rs.getFloat("totentrada");
                            tcd+=rs.getFloat("totalcossal");
                            tpv+=rs.getFloat("totalprepub");
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }

                   fnewRow[0]="<html><h3>Totales</h3></html>";

                    fnewRow[1]="";
                    fnewRow[2]="";
                    fnewRow[3]="";
                    fnewRow[4]="";
                    fnewRow[5]="<html><h3>"+miformat.format(tpz)+"</h3></html>";
                    fnewRow[6]="<html><h3>"+miformat.format(tc)+"</h3></html>";
                    fnewRow[7]="<html><h3>"+miformat.format(tcd)+"</h3></html>";
                    fnewRow[8]="<html><h3>"+miformat.format(tpv)+"</h3></html>";
                    jtable_modelo.addRow(fnewRow);
       this.centrar_datos();
}
    private String  fechaeuropea(String fecha) {
         //resibe cadena de fecha en formato americano yyyy-MM-dd
        java.util.Date fechaestaeuropa=null;
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("dd-MM-yyyy");
       String cadenafecha="";
        try
         {
          fechaestaeuropa = formateadoresta.parse(fecha);
         }
        catch (ParseException e)
          {
             //Error, la cadena de texto no se puede convertir en fecha.
          }
       cadenafecha= formateadorestaeuropa.format(fechaestaeuropa);
       return cadenafecha;
    }
  private String DiaSemana(String fe) {
       String dia = "";
       java.util.Date fecha=null;
         try
            {
                fecha = formateadoresta.parse(fe);
            }
        catch (ParseException e)
            {
                //Error, la cadena de texto no se puede convertir en fecha.
            }
        Calendar cal= Calendar.getInstance();
        cal.setTime(fecha);
        //ojo para establecer o recetear cada parte de la fecha por separado
        //cal.set(Calendar.YEAR, fecha.getYear());
        //cal.set(Calendar.MONTH, fecha.getMonth());
        //cal.set(Calendar.DAY_OF_MONTH, fecha.getDay());
        int diaInt = cal.get(Calendar.DAY_OF_WEEK);
        switch (diaInt) {
            case 1:
                dia = "Domingo";
                break;
            case 2:
                dia = "Lunes";
                break;
            case 3:
                dia = "Martes";
                break;
            case 4:
                dia = "Miercoles";
                break;
            case 5:
                dia = "Jueves";
                break;
            case 6:
                dia = "Viernes";
                break;
            case 7:
                dia = "Sabado";
                break;

        }
        return dia;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jbtn_helayudame = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtb_catalogo_articulos = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }}
            ;
            jtf_busqueda = new javax.swing.JTextField();
            jbtn_buscar = new javax.swing.JButton();
            jLabel15 = new javax.swing.JLabel();
            jtf_viajedescribe = new javax.swing.JTextField();
            jLabel37 = new javax.swing.JLabel();
            jtf_viajeinicial = new javax.swing.JTextField();
            jLabel16 = new javax.swing.JLabel();
            jtf_viajeobservaciones = new javax.swing.JTextField();
            jbtn_crearviaje = new javax.swing.JButton();
            jMenuBar1 = new javax.swing.JMenuBar();
            jMenu1 = new javax.swing.JMenu();
            jmni_salir = new javax.swing.JMenuItem();
            jMenu2 = new javax.swing.JMenu();
            jmni_actualizar = new javax.swing.JMenuItem();
            jmni_escape = new javax.swing.JMenuItem();
            jMenuItem1 = new javax.swing.JMenuItem();

            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(com_distri_clasif_viajes.class);
            setTitle(resourceMap.getString("Form.title")); // NOI18N
            setName("Form"); // NOI18N

            jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
            jPanel3.setName("jPanel3"); // NOI18N

            jbtn_helayudame.setText(resourceMap.getString("jbtn_helayudame.text")); // NOI18N
            jbtn_helayudame.setName("jbtn_helayudame"); // NOI18N
            jbtn_helayudame.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jbtn_helayudameActionPerformed(evt);
                }
            });

            jScrollPane1.setName("jScrollPane1"); // NOI18N

            jtb_catalogo_articulos.setFont(resourceMap.getFont("jtb_catalogo_articulos.font")); // NOI18N
            jtb_catalogo_articulos.setModel(this.jtable_modelo);
            jtb_catalogo_articulos.setName("jtb_catalogo_articulos"); // NOI18N
            jtb_catalogo_articulos.setRowHeight(20);
            jtb_catalogo_articulos.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jtb_catalogo_articulosMouseClicked(evt);
                    if(evt.getClickCount() >= 2)
                    {
                        dioclick(evt);
                        //System.out.println(" double click" );
                    }
                }
            });
            jScrollPane1.setViewportView(jtb_catalogo_articulos);

            jtf_busqueda.setToolTipText(resourceMap.getString("jtf_busqueda.toolTipText")); // NOI18N
            jtf_busqueda.setName("jtf_busqueda"); // NOI18N
            jtf_busqueda.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jtf_busquedaActionPerformed(evt);
                }
            });

            jbtn_buscar.setIcon(resourceMap.getIcon("jbtn_buscar.icon")); // NOI18N
            jbtn_buscar.setText(resourceMap.getString("jbtn_buscar.text")); // NOI18N
            jbtn_buscar.setName("jbtn_buscar"); // NOI18N
            jbtn_buscar.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jbtn_buscarActionPerformed(evt);
                }
            });

            jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
            jLabel15.setName("jLabel15"); // NOI18N

            jtf_viajedescribe.setName("jtf_viajedescribe"); // NOI18N
            jtf_viajedescribe.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jtf_viajedescribeActionPerformed(evt);
                }
            });

            jLabel37.setText(resourceMap.getString("jLabel37.text")); // NOI18N
            jLabel37.setName("jLabel37"); // NOI18N

            jtf_viajeinicial.setFont(resourceMap.getFont("jtf_viajeinicial.font")); // NOI18N
            jtf_viajeinicial.setToolTipText(resourceMap.getString("jtf_viajeinicial.toolTipText")); // NOI18N
            jtf_viajeinicial.setName("jtf_viajeinicial"); // NOI18N
            jtf_viajeinicial.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jtf_viajeinicialActionPerformed(evt);
                }
            });

            jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
            jLabel16.setName("jLabel16"); // NOI18N

            jtf_viajeobservaciones.setName("jtf_viajeobservaciones"); // NOI18N
            jtf_viajeobservaciones.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jtf_viajeobservacionesActionPerformed(evt);
                }
            });

            jbtn_crearviaje.setIcon(resourceMap.getIcon("jbtn_crearviaje.icon")); // NOI18N
            jbtn_crearviaje.setText(resourceMap.getString("jbtn_crearviaje.text")); // NOI18N
            jbtn_crearviaje.setToolTipText(resourceMap.getString("jbtn_crearviaje.toolTipText")); // NOI18N
            jbtn_crearviaje.setName("jbtn_crearviaje"); // NOI18N
            jbtn_crearviaje.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jbtn_crearviajeActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
            jPanel3.setLayout(jPanel3Layout);
            jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addGap(18, 18, 18)
                    .addComponent(jLabel15)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jtf_viajedescribe, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 78, Short.MAX_VALUE)
                    .addComponent(jLabel37)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jtf_viajeinicial, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel16)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jtf_viajeobservaciones, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jbtn_crearviaje)
                    .addGap(40, 40, 40)
                    .addComponent(jbtn_helayudame))
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addGap(352, 352, 352)
                    .addComponent(jtf_busqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(33, 33, 33)
                    .addComponent(jbtn_buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(372, Short.MAX_VALUE))
                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1027, Short.MAX_VALUE)
            );
            jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jbtn_buscar)
                        .addComponent(jtf_busqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jbtn_helayudame)
                        .addComponent(jLabel15)
                        .addComponent(jtf_viajedescribe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jbtn_crearviaje)
                        .addComponent(jtf_viajeobservaciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel16)
                        .addComponent(jtf_viajeinicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel37)))
            );

            jMenuBar1.setName("jMenuBar1"); // NOI18N

            jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
            jMenu1.setName("jMenu1"); // NOI18N

            jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
            jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
            jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
            jmni_salir.setName("jmni_salir"); // NOI18N
            jmni_salir.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jmni_salirActionPerformed(evt);
                }
            });
            jMenu1.add(jmni_salir);

            jMenuBar1.add(jMenu1);

            jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
            jMenu2.setName("jMenu2"); // NOI18N
            jMenu2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenu2ActionPerformed(evt);
                }
            });

            jmni_actualizar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0));
            jmni_actualizar.setText(resourceMap.getString("jmni_actualizar.text")); // NOI18N
            jmni_actualizar.setName("jmni_actualizar"); // NOI18N
            jmni_actualizar.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jmni_actualizarActionPerformed(evt);
                }
            });
            jMenu2.add(jmni_actualizar);

            jmni_escape.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
            jmni_escape.setText(resourceMap.getString("jmni_escape.text")); // NOI18N
            jmni_escape.setName("jmni_escape"); // NOI18N
            jmni_escape.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jmni_escapeActionPerformed(evt);
                }
            });
            jMenu2.add(jmni_escape);

            jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
            jMenuItem1.setName("jMenuItem1"); // NOI18N
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem1ActionPerformed(evt);
                }
            });
            jMenu2.add(jMenuItem1);

            jMenuBar1.add(jMenu2);

            setJMenuBar(jMenuBar1);

            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            );

            pack();
        }// </editor-fold>//GEN-END:initComponents

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "Realmente Desea Salir?")==0)
                {
                    this.dispose();
                }
    }//GEN-LAST:event_jmni_salirActionPerformed

    private void jmni_escapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_escapeActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_escapeActionPerformed

    private void jbtn_helayudameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_helayudameActionPerformed
        // TODO add your handling code here:
        //this.ayuda();
}//GEN-LAST:event_jbtn_helayudameActionPerformed

    private void jmni_actualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_actualizarActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "Realmente Desea Actualizar?")==0)
                {
                   this.cargar_datos(3, 0, "");
                }

    }//GEN-LAST:event_jmni_actualizarActionPerformed

    private void jtf_busquedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_busquedaActionPerformed
        // TODO add your handling code here:
        this.jbtn_buscarActionPerformed(evt);
}//GEN-LAST:event_jtf_busquedaActionPerformed

    private void jbtn_buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_buscarActionPerformed
        // TODO add your handling code here:
        // this.jtf_busqueda.getText();
        if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus Datos?")==0) {
            this.cargar_datos(4,0,this.jtf_busqueda.getText().toString().toUpperCase().trim());

        } else {
            this.jtf_busqueda.requestFocus();
        }


    }//GEN-LAST:event_jbtn_buscarActionPerformed

    private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed
   
    }//GEN-LAST:event_jMenu2ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
             try {
            // TODO add your handling code here:
            this.jtb_catalogo_articulos.print();
        } catch (PrinterException ex) {
            Logger.getLogger(com_distri_clasif_viajes.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jtf_viajedescribeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_viajedescribeActionPerformed
        // TODO add your handling code here:
        this.jtf_viajeinicial.requestFocus();
    }//GEN-LAST:event_jtf_viajedescribeActionPerformed

    private void jtf_viajeinicialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_viajeinicialActionPerformed
        // TODO add your handling code here:
        this.jtf_viajeobservaciones.requestFocus();
}//GEN-LAST:event_jtf_viajeinicialActionPerformed

    private void jtf_viajeobservacionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_viajeobservacionesActionPerformed
        // TODO add your handling code here:
        this.jbtn_crearviaje.requestFocus();
}//GEN-LAST:event_jtf_viajeobservacionesActionPerformed

    private void jbtn_crearviajeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_crearviajeActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "Estan Correctos los Datos?")==0) {
            int folio=0;
            String textosql="select * from x1distribucion_terminados_viajes_actualiza(3,'','"+this.jtf_viajedescribe.getText().toUpperCase().trim()+"','','','"+this.jtf_viajeobservaciones.getText().toUpperCase().trim()+"','"+this.jtf_viajeinicial.getText().toUpperCase().trim()+"');";
            try {
                rs = x.sieuno_executediversosv2(textosql,variables_global.getconexiongral());
                while (rs.next()) {
                    folio = rs.getInt(1);

                }
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
            if (folio==2)
                    {
                        JOptionPane.showMessageDialog(null,"Gracias Viaje Guardado, Si desea Modificarlo visite el Modulo de Viajes", "Sistema Integral: Viajes",1);
                        this.jtf_viajedescribe.setText("");
                        this.cargar_datos(3, 0, "");
                    }
                else
                    {
                        JOptionPane.showMessageDialog(null,"Error Verifiqu con Administrador no se ha podido guardar", "Sistema Integral Error",1);
                    }
        }
    }//GEN-LAST:event_jbtn_crearviajeActionPerformed

 
private void jtb_catalogo_articulosMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }

private void dioclick(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        System.out.println("dio doble  click");
        int fila = jtb_catalogo_articulos.getSelectedRow();
        String idcadena[]=this.jtb_catalogo_articulos.getValueAt(fila, 0).toString().split(":");
        com_distri_clasif_viajes_detalle fcdcvd=new com_distri_clasif_viajes_detalle(idcadena[0],idcadena[1]);
        fcdcvd.pack();
        fcdcvd.setVisible(true);
        //setVisible(false);
    }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new com_distri_clasif_viajes().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtn_buscar;
    private javax.swing.JButton jbtn_crearviaje;
    private javax.swing.JButton jbtn_helayudame;
    private javax.swing.JMenuItem jmni_actualizar;
    private javax.swing.JMenuItem jmni_escape;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JTable jtb_catalogo_articulos;
    private javax.swing.JTextField jtf_busqueda;
    private javax.swing.JTextField jtf_viajedescribe;
    private javax.swing.JTextField jtf_viajeinicial;
    private javax.swing.JTextField jtf_viajeobservaciones;
    // End of variables declaration//GEN-END:variables

}
